package com.example.entity;


import com.example.Ordermodule.OrderItemm;
import com.example.Ordermodule.Orderm;

import java.math.BigDecimal;
import java.time.LocalDate;



public class StandardOrder extends Orderm {
    private String orderStatus;    // 对应 orders 表的 order_status
    private BigDecimal totalPrice; // 对应 orders 表的 total_price
    private Integer buyerId;       // 对应 orders 表的 buyer_id
    private LocalDate createdAt;   // 对应 orders 表的 created_at
    private LocalDate updatedAt;   // 对应 orders 表的 updated_at //


    @Override
    public void validate() {

    }
    // 计算并直接设置总价的方法
    public void calculateTotalPrice() {
        BigDecimal total = BigDecimal.ZERO;
        for (OrderItemm item : items) {
            total = total.add(item.calculatePrice());  // 累加每个商品的价格
        }
        this.totalPrice = total;  // 设置 totalPrice 字段为总价
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public BigDecimal getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Integer getBuyerId() {
        return buyerId;
    }

    public void setBuyerId(Integer buyerId) {
        this.buyerId = buyerId;
    }

    public LocalDate getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDate updatedAt) {
        this.updatedAt = updatedAt;
    }

    public LocalDate getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDate createdAt) {
        this.createdAt = createdAt;
    }
}
